package com.slj.springcloud.controller;

import com.slj.springcloud.model.response.Result;
import org.springframework.web.bind.annotation.*;

import java.util.concurrent.TimeUnit;

@RestController
@RequestMapping("/pay")
public class PayResilienceController {
    @GetMapping("/resilience")
    public Result<String> resilience(@RequestParam("id") Long id) {
        if (id.equals(1L)) {
            throw new RuntimeException("系统错误....");
        }
        if (id.equals(-1L)) {
            try {
                TimeUnit.SECONDS.sleep(8);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
        return Result.success("成功,数据返回...");
    }
}
